// 2025/4/3
// https://leetcode.cn/problems/majority-element/description/?envType=study-plan-v2&envId=top-100-liked
// 多数元素

class Solution {
    public:
        int majorityElement(vector<int>& nums) {
            int candidate, count = 0;
            for(auto& e : nums)
            {
                if(count == 0) candidate = e;
                if(candidate == e) count++;
                else count--;
            }
            return candidate;
        }
    };